import json
import requests
import xlrd


def pos_merinfo():
    array = {'road_name': 'w45345', 'bus_plate': '', 'timeline': '', 'road_type': '', 'site': ''}
    print(array)
    f1 = "Y"
    url = 'http://192.168.77.110:9456/rpc.json?_service=http://service.huifu.com/nsposmas/fposBankMerRegService_1.0.0&_method=register&_param={"req":{"mposFlag":"' + f1 + '","acctNo":"test001","acctNm":"测试001","bankSettleNo":"1010102","province":"广东省","city":"深圳市","district":"龙岗区","merTransType":"0","sysId":"MYE","systemType":"B","orderId":"2022081141086","orderDttm":"20220811374431","gateId":"Ut","merName":"糖豆豆3","merShortName":"糖豆3","merchDistId":"110000","merchAddr":"上海市宜山路700号","regDistId":"320602","regAddr":"上海市宜山路普天产业园","induCode":"5311","licenseCode":"123456","legalName":"胡总","legalCertType":"01","legalCertNo":"340821198301195631","expandType":"1","agentId":"","favPriceFlag":"1","localRegCode":"123456","posSmFlag":"03","posNum":"2","pinKeyFlag":"0","usrName":"小糖豆","usrTel":"18817313372","calcMode":"0.02","dbCalcMode":"0.02","merType":""}}'
    print(url)
    result = requests.get(url)
    print(result.content.decode('utf-8'))
# pos_merinfo()



def read_excel():
    wb = xlrd.open_workbook("snCodeBind.xlsx")
    # 通过sheet_by_name()或者sheet_by_index()方法打开工作表对象
    sheet_1 = wb.sheet_by_name('sn_test')  # 或者sheet_1 = wb.sheet_by_index(0)
    # 通过ncols和nrows 分别获得工作表的列数和行数
    row = sheet_1.nrows
    clo = sheet_1.ncols
    # 通过cell().value方法获得单元格的数值
    header = {}
    for i in range(0, clo):
        sheet_1.cell(0, i).value
        header[i] = sheet_1.cell(0, i).value
    print(header)
    for i in range(1, row):
        excel_row = {}
        for j in range(0, clo):
            excel_row[header[j]] = sheet_1.cell(i, j).value
        print(excel_row)
        json_str = json.dumps(excel_row,ensure_ascii=False)
        url = 'http://192.168.77.110:9456/rpc.json?_service=http://service.huifu.com/nsposmas/fposBankMerRegService_1.0.0&_method=register&_param={"req":' + json_str + '}'
        print(url)
read_excel()


